package view

import (
	"context"
	"fmt"
	"miao-wails/backed/app/service"
	"miao-wails/backed/global"
	"miao-wails/backed/structs/base"
)

// App struct
type App struct {
	ctx context.Context
}

// NewApp creates a new App application struct
func NewApp() *App {
	return &App{}
}

// Startup is called when the app starts. The context is saved
// so we can call the runtime methods
func (a *App) Startup(ctx context.Context) {
	a.ctx = ctx
}

// Shutdown 应用结束时调用方法
func (a *App) Shutdown(ctx context.Context) {
	fmt.Println("app shutdown")
}

// Greet returns a greeting for the given name
func (a *App) Greet(name string) string {
	return fmt.Sprintf("Hello %s, It's show time!", name)
}

func (a *App) SayHi(name string) string {
	return "Hi " + name
}

func (a *App) GoLogs(logStr string) {
	service.RtcSer.WriteLogs(logStr)
}

func (a *App) LoadModuleConfig() (conf base.ModuleConfig) {
	return global.Conf.ModuleConfig
}
